﻿using System.Linq;
using System.Collections.Generic;

namespace Eugenhome.Atrium.Rss.Web
{
    /// <summary>
    /// 
    /// </summary>
    public class RssItem
    {
        /// <summary></summary>
        private Rss _rss;

        /// <summary></summary>
        public string DisplayName { get { return string.Format("{0} - {1}", _rss.Title, DescriptionWithoutHtml); } }

        /// <summary></summary>
        public string Title { get { return _rss.Title; } }
        /// <summary></summary>
        public string Link { get { return _rss.Link; } }
        /// <summary></summary>
        public string Description { get { return DescriptionWithoutHtml; } }

        /// <summary></summary>
        private string DescriptionWithoutHtml
        {
            get
            {
                string description = _rss.Description;
                if (!_rss.Description.IndexOf('<').Equals(-1))
                {
                    description = _rss.Description.Substring(0, _rss.Description.IndexOf('<'));
                }
                return description;
            }
        }

        /// <summary>
        ///  
        /// </summary>
        /// <param name="rss"></param>
        public RssItem(Rss rss)
        {
            _rss = rss;
        }


    }
}